package com.bacon.gmall.user.service.impl;

import com.bacon.gmall.common.util.MD5;
import com.bacon.gmall.model.user.UserInfo;
import com.bacon.gmall.user.mapper.LoginInfoMapper;
import com.bacon.gmall.user.service.LoginService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author： bacon、
 * @version： 1.0
 * @create： 2021-01-03 19:34
 * @description:
 */
@Service
public class LoginServiceImpl implements LoginService {

    @Autowired
    private LoginInfoMapper loginMapper;

    @Override
    public UserInfo login(UserInfo userInfo) {
        return loginMapper.selectOne(
                new QueryWrapper<UserInfo>().
                eq("login_name",userInfo.getLoginName()).
                eq("passwd", MD5.encrypt(userInfo.getPasswd())));
    }
}
